package abcy.cloud.syscoreserver.controller;

import abcy.cloud.blogcommon.resp.ResponseEntity;
import abcy.cloud.syscoreserver.dto.req.SysPermissionAddReqDto;
import abcy.cloud.syscoreserver.services.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/syspermission")
public class SysPermissionController {

    @Autowired
    private SysPermissionService sysPermissionService;

    @PostMapping(value = "/getPermissions")
    public Map<String, Object> getPermissions(@RequestBody Map<String, Object> map) {
        return sysPermissionService.selectPermissionByConditions(map);
    }

    @PostMapping(value = "/addPermission")
    public ResponseEntity addPermission(@RequestBody SysPermissionAddReqDto sysPermissionAddReqDto) {
        sysPermissionService.addPermission(sysPermissionAddReqDto);
        return ResponseEntity.success("新增权限成功");
    }
}
